package com.frkj.yuan.activity;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import com.frkj.yuan.R;
import com.frkj.yuan.adapter.StoredMoneyAdapter;
import com.frkj.yuan.base.BaseActivity;
import com.frkj.yuan.fragment.my.StoredMoneyChiZhiFragment;
import com.frkj.yuan.fragment.my.StoredMoneyXiaoFeiFragment;
import com.frkj.yuan.utils.FullScreenUtils;

import java.util.ArrayList;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * 界面:  StoredMoneyActivity界面
 * company: 兰州丰荣信息科技有限公司
 * 创建时间: on 2022/2/25 10 ：22
 * 项目名称：yuanban
 */
public class StoredMoneyActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener, ViewPager.OnPageChangeListener {
    @BindView(R.id.viewPager)
    ViewPager mViewPager;
    @BindView(R.id.base_title)
    TextView mTitleMsg;
    @BindView(R.id.rag_group)
    RadioGroup mRadgroup;
    private ArrayList<Fragment> mList = new ArrayList<>();
    @Override
    public int getLayoutId() {
        return R.layout.activity_stored_money;
    }
    @Override
    public void initLayoutView() {
        FullScreenUtils.getInstance().fullScreen(StoredMoneyActivity.this,true);

        mTitleMsg.setText("储值金");
        initfragment();
        mViewPager.setCurrentItem(0);
        mRadgroup.check(R.id.rad_detials);
        mRadgroup.setOnCheckedChangeListener(this);
        mViewPager.setOnPageChangeListener(this);
        mViewPager.setAdapter(new StoredMoneyAdapter(getSupportFragmentManager(), mList));
    }

    private void initfragment() {
        StoredMoneyChiZhiFragment chiZhiFragment = new StoredMoneyChiZhiFragment();
        mList.add(chiZhiFragment);
        StoredMoneyXiaoFeiFragment xiaoFeiFragment = new StoredMoneyXiaoFeiFragment();
        mList.add(xiaoFeiFragment);
    }
    @OnClick({R.id.base_back,R.id.to_recharge})
    public void OnClick(View view){
        switch (view.getId()){
            case R.id.base_back:
                finishWitchAnimation();
                break;
            case R.id.to_recharge:
                openActivityWitchAnimation(RechargeMoneyActivity.class);
                break;
        }
    }
    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.rad_chizhi:
                mViewPager.setCurrentItem(0, false);
                break;
            case R.id.rad_xiaofei:
                mViewPager.setCurrentItem(1, false);
                break;
        }
    }
    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }
    @Override
    public void onPageSelected(int position) {
        switch (position) {
            case 0:
                mRadgroup.check(R.id.rad_chizhi);
                break;
            case 1:
                mRadgroup.check(R.id.rad_xiaofei);
                break;
        }
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }
}
